package com.lin.filegraph.utils.threshold;

/**
 * @description:
 * @author: linhuaixu
 * @time: 2023/5/18 10:27
 */

public class Threshold {
    public static final double DependSim = 1;//域节点合并相似度
    public static final double inputComSep = 0.6;//架构输入独立组件相似度
    public static final double inputComSim = 0.6;//架构输入组件命名相似度
    public static final double COMSCALE = 0.3;//组件最大规模
    public static final double comScale2 = 0.5;//组件最大规模浮动范围
    public static final int regionPreMin = 3;//独立性依赖最大边
    public static final double dirSim = 0.3;//目录相似度底限
    public static final double maxMultiple = 1.5;
    public static final double preReName = 0.5;//聚合节点是否保留前版本的命名
    public static final double reNameSep = 0.3;//独立组件根据文件命名
    public static final double reNameSim = 0.5;//重命名根据文件命名
    public static final double reNamePercent = 0.7;//根据文件命名
    public static final double minDependPercent = 0.7;//最小依赖缩小倍数
    public static final double minComSim = 0.4;//组件最小相似
    public static double MINCOM = 10;//小组件文件数
    public static int filesize=40;
    public static int k1=20;//组件最多为20
    public static final double MINMINCOM = 5;//小组件文件数5
    public static final String ROOT ="[ROOT]";
    public static final String UNKNOWN ="[UNKNOWN]";
    public static final String SPACER ="#";
    public static final String JOINER ="-";
    public static final String TEST ="TEST";
    public static final double DISPLAYPercent =0.2;
    //by suxiao wei  simrank damp 和 t
    public static final double damp=0.8;
    public static final double t=0.0;
    public static final int maxIteration=10;
    public static final double avgCoefficient=1.2;
    public static final double avgCoefficient1=1;
    //每次更新更新n/k个节点
    public static final double k=0.1;
    public static final int scale=8;
    public static final int couplingInCount = 3;//文件图预处理过程判断耦合文件的入度参数
    public static final int couplingOutCount = 1;//文件图预处理过程判断耦合文件的出度参数
    public static final double loopRatio = 0.5;//闭环依赖最大聚类规模
    public static final double COMSCALE_DIR = 0.1;
    //
    public static final int CompNumControl = 20;
    public static final int FileSize=40;//小组件文件数目小于40,被聚合

    /**
     * 对于组件最大数量进行分级
     */
    public static int getMaxComNum(double arcSize) {
        int max = 0;
        if (arcSize < 200) {
            max =4;//8
        } else if (200 <= arcSize && arcSize < 400) {
            max = 7;//15
        } else if(400 <= arcSize && arcSize < 800){
            max = 12;//20
        }else {
            max = (int) (16<arcSize * 0.015?16:arcSize * 0.015);//30
        }
        // 上限3-20
        int temp =(int) Math.round(arcSize * 0.025);
        int maxNum = max < temp ? max : temp;
        if(maxNum<3)
            maxNum=3;
        return maxNum;
    }

    /**
     * 对于组件最小值数量进行分级
     */
    public static double getMinComNum(double arcSize) {
        // 下限3-8
        double minNum = Math.ceil(arcSize * 0.08);
        if(minNum<3)
            minNum = 3;
        if(minNum>8)
            minNum=8;
        return minNum;
    }


    /**
     * 域节点边的数量的分级
     */
    public static int getRegionEdgeNum(double arcSize) {
        int regEdgeNum = 0;
        if (arcSize < 200) {
            regEdgeNum = 6;
        } else if (200 <= arcSize && arcSize < 700) {
            regEdgeNum  = 10;
        } else {
            regEdgeNum = 15;
        }
        return regEdgeNum;
    }

    /**
     * 域节点总数范围
     */
    public static int getRegionNum(double arcSize) {
        int regNum = 0;
        if (arcSize < 200) {
            regNum = (int) Math.min(arcSize*0.1, 15);
        } else if (200 <= arcSize && arcSize < 700) {
            regNum  = (int) Math.min(arcSize*0.1, 50);
        } else {
            regNum = (int) Math.min(arcSize*0.1, 100);
        }
        return regNum;
    }

    public static double getDirGrade(double sim) {
        if(sim>0.7)
            sim = 1;
        else if(sim>0.4&&sim<=0.7)
            sim=0.8;
        else if(sim>0.2&&sim<=0.4)
            sim=0.6;
        else
            sim=0.4;
        return sim;
    }



    public static void setMin(double arcSize){
        double num=arcSize*0.01;
        num=Math.min(num, 30);
        MINCOM=Math.max(num, 10);
    }
}

